简体   繁体   中英

Path issue to root directory

I am currently trying to run the coin_flip_traders_v1.0.py script from the Darwinex ZeroMQ Python library here -> https://github.com/darwinex/dwx-zeromq-connector/tree/master/v2.0.1/python

However, I am having some trouble with the path that it says at the top of the file to point to the root directory.

I have changed it to _path = '../../..' Which should take me to the project root. However I get the error:

File "/Users/Al/Desktop/Trading/examples/template/strategies/base/DWX_ZMQ_Strategy.py", line 20, in os.chdir(_path) NameError: name '_path' is not defined

I then changed the path for the DWX_ZMQ_Strategy.py to _path = '../../../..'

I then get the error:

File "/Users/Al/Desktop/Trading/examples/template/strategies/base/DWX_ZMQ_Strategy.py", line 24, in from api.DWX_ZeroMQ_Connector_v2_0_1_RC8 import DWX_ZeroMQ_Connector ModuleNotFoundError: No module named 'api'

I am thinking that it has something to do with the way I am setting the path to the root directory, but not sure where I am going wrong.

If it helps, I am running python 3.6.8 and the command I am executing to run the script is exec(open("coin_flip_traders_v1.0.py").read())

The problem is not a ZeroMQ-related problem.

For diagnosing the rest, the successful file-system tree-navigation, start with using this:

print( "DEBUG: now uses this directory-tree {0:} node".format( os.getcwd ) )
...
os.chdir( anyMaskForRelativeOrAbsoluteTreeMOVE ) # no ~-"expansions"
...
print( "DEBUG: now uses this directory-tree {0:} node".format( os.getcwd ) )

Also kindly note, you must reach such a directory, where the API was installed, not the "root"-directory of the whole filesystem. Check where your DWX installation is actually located and direct the os.chdir() -move to reach that point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM